package impl

import (
	"blog/internal/models"
	"gorm.io/gorm"
)

type ProfileRepository struct {
	db *gorm.DB
}

func NewProfileRepository(db *gorm.DB) *ProfileRepository {
	return &ProfileRepository{db: db}
}

func (p *ProfileRepository) FindByUid(uid uint64) (*models.Profile, error) {
	var profile models.Profile
	if err := p.db.First(&profile, "uid = ?", uid).Error; err != nil {
		return nil, err
	}
	return &profile, nil
}
